# 导包
from selenium.webdriver.common.by import By
from util_tools.basePage import BasePage
from time import sleep
import allure

class SearchPage(BasePage):
    url = '/search.php'
    advanced_search = (By.LINK_TEXT, '高级搜索')
    keywords = (By.NAME, 'keywords')
    submit = (By.NAME, 'Submit')
    buy_button = (By.LINK_TEXT, '购买')

    def add_cart(self):
        self.open_url(self.url)
        allure.attach(self.url, '打开测试页面', attachment_type=allure.attachment_type.TEXT)
        self.click(self.advanced_search)
        self.send_keys(self.keywords, '测试商品抽纸类')
        self.click(self.submit)
        sleep(3)
        self.click(self.buy_button)
        allure.attach(self.screenshots_png(), '首页搜索框输入截屏', attachment_type=allure.attachment_type.PNG)